package genutil

import (
	"crypto/md5"
	"crypto/sha256"
	"encoding/hex"
)

func Md5Hex(str string) string {
	return Md5HexWithSalt(str, "")
}

func Md5HexWithSalt(str, salt string) string {
	dataMd5 := md5.Sum([]byte(str + salt))
	return hex.EncodeToString(dataMd5[:])
}

func Sha256Hex(str string) string {
	return Sha256HexWithSalt(str, "")
}

func Sha256HexWithSalt(str, salt string) string {
	hash := sha256.Sum256([]byte(str + salt))
	return hex.EncodeToString(hash[:])
}
